home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / steff.hp < prev    next >
Text File  |  1995-03-23  |  4KB  |  46 lines

  1.                                                                                 
  2.      The following finds a solution to g(x) = x given an initial approximation  
  3. p0, using the Steffensen's method.                                              
  4.                                                                                 
  5.       'G' - this variable must contain the funtion to be evaluated              
  6.             e.g. 'X^2-2*X+4'                                                    
  7.                                                                                 
  8.    stack levels:  3: initial approximation                                      
  9.                   2: tolerance level                                            
  10.                   1: maximum number of iterations before aborting               
  11.                                                                                 
  12. 'STEFF'  [ A712 ]                                                               
  13.                                                                                 
  14. << 0 -> p0 tol n0 i                                                             
  15.    << WHILE i n0 <= REPEAT                                                      
  16.          p0 'X' STO G EVAL 'p1' STO                                             
  17.          p1 'X' STO G EVAL 'p2' STO                                             
  18.          p0 p1 p0 - DUP * p2 2 p1 * - p0 + / - 'p' STO                          
  19.          IF p p0 - ABS tol < THEN                                               
  20.             p { p X p1 p2 } PURGE ABORT                                         
  21.          END                                                                    
  22.          i 1 + 'i' STO                                                          
  23.          i p p0 - ABS p p 'X' STO G EVAL 4 ->LIST SHON HALT DROP                
  24.          p 'p0' STO                                                             
  25.       END                                                                       
  26.       'F'                                                                       
  27.    >>                                                                           
  28. >>                                                                              
  29.                                                                                 
  30.      SHON simply turns shift key on.                                            
  31. SHON                                                                            
  32.                                                                                 
  33.   << # 1F8A7h SYSEVAL >>                                                        
  34.                                                                                 
  35.      At each halt of the program a list containing                              
  36.        - iteration step                                                         
  37.        - error limit for this guess                                             
  38.        - current solution                                                       
  39.                                                                                 
  40. Simply press CONT to go on to next iteration step.                              
  41. ********************************************************************            
  42. *       J.J.        *             JJL101@psuvm.bitnet              *            
  43. *                   *    Penn State Center for Academic Computing  *            
  44. *    John Lehett    *          Computational Mathematics           *            
  45. ********************************************************************            
  46.